package us.sunrisemorning.pixivbrower.web.controller;

import java.util.List;

import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;

import us.sunrisemorning.pixivbrower.dao.IllustService;
import us.sunrisemorning.pixivbrower.model.Illust;

public class BrowerController extends Controller {
    
    @Inject
    private IllustService illustService;
    
    public void index() {
        renderTemplate("brower.html");
    }
    
    public void search() {
        String keyword = getPara("keyword");
        String r18only = getPara("r18only");
        boolean r18 = "true".equals(r18only);
        
        List<Illust> resultList = illustService.findByKeyword(keyword, r18);
        
        setAttr("keyword", keyword);
        setAttr("r18only", r18only);
        setAttr("showResult", "true");
        setAttr("results", resultList);
        renderTemplate("brower.html");
    }
}
